import*as e from"../../../../core/i18n/i18n.js";import{assertNotNullOrUndefined as t}from"../../../../core/platform/platform.js";import*as r from"../../../../core/sdk/sdk.js";import*as a from"../../../../ui/components/helpers/helpers.js";import*as i from"../../../../ui/components/legacy_wrapper/legacy_wrapper.js";import*as n from"../../../../ui/components/render_coordinator/render_coordinator.js";import*as o from"../../../../ui/components/report_view/report_view.js";import*as s from"../../../../ui/lit-html/lit-html.js";import*as l from"../../../../ui/components/data_grid/data_grid.js";import*as d from"../../../../core/common/common.js";import*as c from"../../../../ui/components/icon_button/icon_button.js";import*as p from"../../../network/forward/forward.js";const u=new CSSStyleSheet;u.replaceSync("button.link{color:var(--color-link);text-decoration:underline;padding:0;border:none;background:none;font-family:inherit;font-size:inherit;height:16px}button.link devtools-icon{vertical-align:sub}\n/*# sourceURL=preloadingDetailsReportView.css */\n");const g={PrefetchFailedIneligibleRedirect:"The prefetch was redirected, but the redirect URL is not eligible for prefetch.",PrefetchFailedInvalidRedirect:"The prefetch was redirected, but there was a problem with the redirect.",PrefetchFailedMIMENotSupported:"The prefetch failed because the response's Content-Type header was not supported.",PrefetchFailedNetError:"The prefetch failed because of a network error.",PrefetchFailedNon2XX:"The prefetch failed because of a non-2xx HTTP response status code.",PrefetchFailedPerPageLimitExceeded:"The prefetch was not performed because the initiating page already has too many prefetches ongoing.",PrefetchIneligibleRetryAfter:"A previous prefetch to the origin got a HTTP 503 response with an Retry-After header that has not elapsed yet.",PrefetchIsPrivacyDecoy:"The URL was not eligible to be prefetched because there was a registered service worker or cross-site cookies for that origin, but the prefetch was put on the network anyways and not used, to disguise that the user had some kind of previous relationship with the origin.",PrefetchIsStale:"Too much time elapsed between the prefetch and usage, so the prefetch was discarded.",PrefetchNotEligibleBrowserContextOffTheRecord:"The prefetch was not performed because the browser is in Incognito or Guest mode.",PrefetchNotEligibleDataSaverEnabled:"The prefetch was not performed because the operating system is in Data Saver mode.",PrefetchNotEligibleExistingProxy:"The URL is not eligible to be prefetched, because in the default network context it is configured to use a proxy server.",PrefetchNotEligibleHostIsNonUnique:"The URL was not eligible to be prefetched because its host was not unique (e.g., a non publicly routable IP address or a hostname which is not registry-controlled), but the prefetch was required to be proxied.",PrefetchNotEligibleNonDefaultStoragePartition:"The URL was not eligible to be prefetched because it uses a non-default storage partition.",PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy:"The URL was not eligible to be prefetched because the default network context cannot be configured to use the prefetch proxy for a same-site cross-origin prefetch request.",PrefetchNotEligibleSchemeIsNotHttps:"The URL was not eligible to be prefetched because its scheme was not https:.",PrefetchNotEligibleUserHasCookies:"The URL was not eligible to be prefetched because it was cross-site, but the user had cookies for that origin.",PrefetchNotEligibleUserHasServiceWorker:"The URL was not eligible to be prefetched because there was a registered service worker for that origin, which is currently not supported.",PrefetchNotUsedCookiesChanged:"The prefetch was not used because it was a cross-site prefetch, and cookies were added for that URL while the prefetch was ongoing, so the prefetched response is now out-of-date.",PrefetchProxyNotAvailable:"A network error was encountered when trying to set up a connection to the prefetching proxy.",PrefetchNotUsedProbeFailed:"The prefetch was blocked by your Internet Service Provider or network administrator.",PrefetchEvicted:"The prefetch was discarded for a newer prefetch because |kPrefetchNewLimits| is enabled",PrefetchNotEligibleBatterySaverEnabled:"The prefetch was not performed because the Battery Saver setting was enabled.",PrefetchNotEligiblePreloadingDisabled:"The prefetch was not performed because preloading was disabled."},h=e.i18n.registerUIStrings("panels/application/preloading/components/PreloadingString.ts",g),m=e.i18n.getLazilyComputedLocalizedString.bind(void 0,h),f={PrefetchFailedIneligibleRedirect:{name:m(g.PrefetchFailedIneligibleRedirect)},PrefetchFailedInvalidRedirect:{name:m(g.PrefetchFailedInvalidRedirect)},PrefetchFailedMIMENotSupported:{name:m(g.PrefetchFailedMIMENotSupported)},PrefetchFailedNetError:{name:m(g.PrefetchFailedNetError)},PrefetchFailedNon2XX:{name:m(g.PrefetchFailedNon2XX)},PrefetchFailedPerPageLimitExceeded:{name:m(g.PrefetchFailedPerPageLimitExceeded)},PrefetchIneligibleRetryAfter:{name:m(g.PrefetchIneligibleRetryAfter)},PrefetchIsPrivacyDecoy:{name:m(g.PrefetchIsPrivacyDecoy)},PrefetchIsStale:{name:m(g.PrefetchIsStale)},PrefetchNotEligibleBrowserContextOffTheRecord:{name:m(g.PrefetchNotEligibleBrowserContextOffTheRecord)},PrefetchNotEligibleDataSaverEnabled:{name:m(g.PrefetchNotEligibleDataSaverEnabled)},PrefetchNotEligibleExistingProxy:{name:m(g.PrefetchNotEligibleExistingProxy)},PrefetchNotEligibleHostIsNonUnique:{name:m(g.PrefetchNotEligibleHostIsNonUnique)},PrefetchNotEligibleNonDefaultStoragePartition:{name:m(g.PrefetchNotEligibleNonDefaultStoragePartition)},PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy:{name:m(g.PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy)},PrefetchNotEligibleSchemeIsNotHttps:{name:m(g.PrefetchNotEligibleSchemeIsNotHttps)},PrefetchNotEligibleUserHasCookies:{name:m(g.PrefetchNotEligibleUserHasCookies)},PrefetchNotEligibleUserHasServiceWorker:{name:m(g.PrefetchNotEligibleUserHasServiceWorker)},PrefetchNotUsedCookiesChanged:{name:m(g.PrefetchNotUsedCookiesChanged)},PrefetchProxyNotAvailable:{name:m(g.PrefetchProxyNotAvailable)},PrefetchNotUsedProbeFailed:{name:m(g.PrefetchNotUsedProbeFailed)},PrefetchEvicted:{name:m(g.PrefetchEvicted)},PrefetchNotEligibleBatterySaverEnabled:{name:m(g.PrefetchNotEligibleBatterySaverEnabled)},PrefetchNotEligiblePreloadingDisabled:{name:m(g.PrefetchNotEligiblePreloadingDisabled)}},S={selectAnElementForMoreDetails:"Select an element for more details",detailsDetailedInformation:"Detailed information",detailsAction:"Action",detailsStatus:"Status",detailsFailureReason:"Failure reason",detailsRuleSet:"Rule set",detailedStatusNotTriggered:"Preloading attempt is not yet triggered.",detailedStatusPending:"Preloading attempt is eligible but pending.",detailedStatusRunning:"Preloading is running.",detailedStatusReady:"Preloading finished and the result is ready for the next navigation.",detailedStatusSuccess:"Preloading finished and used for a navigation.",detailedStatusFailure:"Preloading failed.",prerenderFinalStatusLowEndDevice:"The prerender was not performed because this device does not have enough total system memory to support prerendering.",prerenderFinalStatusInvalidSchemeRedirect:"The prerendering navigation failed because it redirected to a URL whose scheme was not http: or https:.",prerenderFinalStatusInvalidSchemeNavigation:"The URL was not eligible to be prerendered because its scheme was not http: or https:.",prerenderFinalStatusNavigationRequestBlockedByCsp:"The prerendering navigation was blocked by a Content Security Policy.",prerenderFinalStatusMainFrameNavigation:"The prerendered page navigated itself to another URL, which is currently not supported.",prerenderFinalStatusMojoBinderPolicy:"The prerendered page used a forbidden JavaScript API that is currently not supported.",prerenderFinalStatusRendererProcessCrashed:"The prerendered page crashed.",prerenderFinalStatusRendererProcessKilled:"The prerendered page was killed.",prerenderFinalStatusDownload:"The prerendered page attempted to initiate a download, which is currently not supported.",prerenderFinalStatusNavigationBadHttpStatus:"The prerendering navigation failed because of a non-2xx HTTP response status code.",prerenderFinalStatusClientCertRequested:"The prerendering navigation required a HTTP client certificate.",prerenderFinalStatusNavigationRequestNetworkError:"The prerendering navigation encountered a network error.",prerenderFinalStatusMaxNumOfRunningPrerendersExceeded:"The prerender was not performed because the initiating page already has too many prerenders ongoing. Remove other speculation rules to enable further prerendering.",prerenderFinalStatusSslCertificateError:"The prerendering navigation failed because of an invalid SSL certificate.",prerenderFinalStatusLoginAuthRequested:"The prerendering navigation required HTTP authentication, which is currently not supported.",prerenderFinalStatusUaChangeRequiresReload:"Changing User Agent occured in prerendering navigation.",prerenderFinalStatusBlockedByClient:"Some resource load was blocked.",prerenderFinalStatusAudioOutputDeviceRequested:"The prerendered page requested audio output, which is currently not supported.",prerenderFinalStatusMixedContent:"The prerendered page contained mixed content.",prerenderFinalStatusTriggerBackgrounded:"The initiating page was backgrounded, so the prerendered page was discarded.",prerenderFinalStatusMemoryLimitExceeded:"The prerender was not performed because the browser exceeded the prerendering memory limit.",prerenderFinalStatusFailToGetMemoryUsage:"The prerender was not performed because the browser encountered an internal error attempting to determine current memory usage.",prerenderFinalStatusDataSaverEnabled:"The prerender was not performed because the user requested that the browser use less data.",prerenderFinalStatusHasEffectiveUrl:"The initiating page cannot perform prerendering, because it has an effective URL that is different from its normal URL. (For example, the New Tab Page, or hosted apps.)",prerenderFinalStatusTimeoutBackgrounded:"The initiating page was backgrounded for a long time, so the prerendered page was discarded.",prerenderFinalStatusCrossSiteRedirectInInitialNavigation:"The prerendering navigation failed because the prerendered URL redirected to a cross-site URL.",prerenderFinalStatusCrossSiteNavigationInInitialNavigation:"The prerendering navigation failed because it targeted a cross-site URL.",prerenderFinalStatusSameSiteCrossOriginRedirectNotOptInInInitialNavigation:"The prerendering navigation failed because the prerendered URL redirected to a cross-origin same-site URL, but the destination response did not include the appropriate Supports-Loading-Mode header.",prerenderFinalStatusSameSiteCrossOriginNavigationNotOptInInInitialNavigation:"The prerendered page navigated itself to a cross-origin same-site URL, but the destination response did not include the appropriate Supports-Loading-Mode header.",prerenderFinalStatusActivationNavigationParameterMismatch:"The prerender was not used because during activation time, different navigation parameters (e.g., HTTP headers) were calculated than during the original prerendering navigation request.",prerenderFinalStatusPrimaryMainFrameRendererProcessCrashed:"The initiating page crashed.",prerenderFinalStatusPrimaryMainFrameRendererProcessKilled:"The initiating page was killed.",prerenderFinalStatusActivationFramePolicyNotCompatible:"The prerender was not used because the sandboxing flags or permissions policy of the initiating page was not compatible with those of the prerendering page.",prerenderFinalStatusPreloadingDisabled:"The prerender was not performed because the user disabled preloading in their browser settings.",prerenderFinalStatusBatterySaverEnabled:"The prerender was not performed because the user requested that the browser use less battery.",prerenderFinalStatusActivatedDuringMainFrameNavigation:"Prerendered page activated during initiating page's main frame navigation.",prerenderFinalStatusCrossSiteRedirectInMainFrameNavigation:"The prerendered page navigated to a URL which redirected to a cross-site URL.",prerenderFinalStatusCrossSiteNavigationInMainFrameNavigation:"The prerendered page navigated to a cross-site URL.",prerenderFinalStatusSameSiteCrossOriginRedirectNotOptInInMainFrameNavigation:"The prerendered page navigated to a URL which redirected to a cross-origin same-site URL, but the destination response did not include the appropriate Supports-Loading-Mode header.",prerenderFinalStatusSameSiteCrossOriginNavigationNotOptInInMainFrameNavigation:"The prerendered page navigated to a cross-origin same-site URL, but the destination response did not include the appropriate Supports-Loading-Mode header.",prerenderFinalStatusMemoryPressureOnTrigger:"The prerender was not performed because the browser was under critical memory pressure.",prerenderFinalStatusMemoryPressureAfterTriggered:"The prerendered page was unloaded because the browser came under critical memory pressure.",prerenderFinalStatusPrerenderingDisabledByDevTools:"The prerender was not performed because DevTools has been used to disable prerendering.",prerenderFinalStatusResourceLoadBlockedByClient:"Some resource load was blocked."},R=e.i18n.registerUIStrings("panels/application/preloading/components/PreloadingDetailsReportView.ts",S),v=e.i18n.getLocalizedString.bind(void 0,R);class w{static action({key:t}){switch(t.action){case"Prefetch":return e.i18n.lockedString("prefetch");case"Prerender":return e.i18n.lockedString("prerender")}}static detailedStatus({status:t}){switch(t){case"NotTriggered":return v(S.detailedStatusNotTriggered);case"Pending":return v(S.detailedStatusPending);case"Running":return v(S.detailedStatusRunning);case"Ready":return v(S.detailedStatusReady);case"Success":return v(S.detailedStatusSuccess);case"Failure":return v(S.detailedStatusFailure);case"NotSupported":return e.i18n.lockedString("Internal error")}}static failureReason({prerenderStatus:t}){switch(t){case null:case"Activated":return null;case"Destroyed":case"DidFailLoad":case"Stop":return e.i18n.lockedString("Unknown");case"LowEndDevice":return v(S.prerenderFinalStatusLowEndDevice);case"InvalidSchemeRedirect":return v(S.prerenderFinalStatusInvalidSchemeRedirect);case"InvalidSchemeNavigation":return v(S.prerenderFinalStatusInvalidSchemeNavigation);case"InProgressNavigation":case"TriggerDestroyed":case"NavigationNotCommitted":case"EmbedderTriggeredAndCrossOriginRedirected":case"ActivatedBeforeStarted":case"InactivePageRestriction":case"StartFailed":case"ActivatedInBackground":case"ActivationNavigationDestroyedBeforeSuccess":return e.i18n.lockedString("Internal error");case"NavigationRequestBlockedByCsp":return v(S.prerenderFinalStatusNavigationRequestBlockedByCsp);case"MainFrameNavigation":return v(S.prerenderFinalStatusMainFrameNavigation);case"MojoBinderPolicy":return v(S.prerenderFinalStatusMojoBinderPolicy);case"RendererProcessCrashed":return v(S.prerenderFinalStatusRendererProcessCrashed);case"RendererProcessKilled":return v(S.prerenderFinalStatusRendererProcessKilled);case"Download":return v(S.prerenderFinalStatusDownload);case"NavigationBadHttpStatus":return v(S.prerenderFinalStatusNavigationBadHttpStatus);case"ClientCertRequested":return v(S.prerenderFinalStatusClientCertRequested);case"NavigationRequestNetworkError":return v(S.prerenderFinalStatusNavigationRequestNetworkError);case"MaxNumOfRunningPrerendersExceeded":return v(S.prerenderFinalStatusMaxNumOfRunningPrerendersExceeded);case"CancelAllHostsForTesting":case"EmbedderHostDisallowed":case"TabClosedByUserGesture":case"TabClosedWithoutUserGesture":case"PreloadingUnsupportedByWebContents":throw new Error("unreachable");case"SslCertificateError":return v(S.prerenderFinalStatusSslCertificateError);case"LoginAuthRequested":return v(S.prerenderFinalStatusLoginAuthRequested);case"UaChangeRequiresReload":return v(S.prerenderFinalStatusUaChangeRequiresReload);case"BlockedByClient":return v(S.prerenderFinalStatusBlockedByClient);case"AudioOutputDeviceRequested":return v(S.prerenderFinalStatusAudioOutputDeviceRequested);case"MixedContent":return v(S.prerenderFinalStatusMixedContent);case"TriggerBackgrounded":return v(S.prerenderFinalStatusTriggerBackgrounded);case"MemoryLimitExceeded":return v(S.prerenderFinalStatusMemoryLimitExceeded);case"FailToGetMemoryUsage":return v(S.prerenderFinalStatusFailToGetMemoryUsage);case"DataSaverEnabled":return v(S.prerenderFinalStatusDataSaverEnabled);case"HasEffectiveUrl":return v(S.prerenderFinalStatusHasEffectiveUrl);case"TimeoutBackgrounded":return v(S.prerenderFinalStatusTimeoutBackgrounded);case"CrossSiteRedirectInInitialNavigation":return v(S.prerenderFinalStatusCrossSiteRedirectInInitialNavigation);case"CrossSiteNavigationInInitialNavigation":return v(S.prerenderFinalStatusCrossSiteNavigationInInitialNavigation);case"SameSiteCrossOriginRedirectNotOptInInInitialNavigation":return v(S.prerenderFinalStatusSameSiteCrossOriginRedirectNotOptInInInitialNavigation);case"SameSiteCrossOriginNavigationNotOptInInInitialNavigation":return v(S.prerenderFinalStatusSameSiteCrossOriginNavigationNotOptInInInitialNavigation);case"ActivationNavigationParameterMismatch":return v(S.prerenderFinalStatusActivationNavigationParameterMismatch);case"PrimaryMainFrameRendererProcessCrashed":return v(S.prerenderFinalStatusPrimaryMainFrameRendererProcessCrashed);case"PrimaryMainFrameRendererProcessKilled":return v(S.prerenderFinalStatusPrimaryMainFrameRendererProcessKilled);case"ActivationFramePolicyNotCompatible":return v(S.prerenderFinalStatusActivationFramePolicyNotCompatible);case"PreloadingDisabled":return v(S.prerenderFinalStatusPreloadingDisabled);case"BatterySaverEnabled":return v(S.prerenderFinalStatusBatterySaverEnabled);case"ActivatedDuringMainFrameNavigation":return v(S.prerenderFinalStatusActivatedDuringMainFrameNavigation);case"CrossSiteRedirectInMainFrameNavigation":return v(S.prerenderFinalStatusCrossSiteRedirectInMainFrameNavigation);case"CrossSiteNavigationInMainFrameNavigation":return v(S.prerenderFinalStatusCrossSiteNavigationInMainFrameNavigation);case"SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation":return v(S.prerenderFinalStatusSameSiteCrossOriginRedirectNotOptInInMainFrameNavigation);case"SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation":return v(S.prerenderFinalStatusSameSiteCrossOriginNavigationNotOptInInMainFrameNavigation);case"MemoryPressureOnTrigger":return v(S.prerenderFinalStatusMemoryPressureOnTrigger);case"MemoryPressureAfterTriggered":return v(S.prerenderFinalStatusMemoryPressureAfterTriggered);case"PrerenderingDisabledByDevTools":return v(S.prerenderFinalStatusPrerenderingDisabledByDevTools);case"ResourceLoadBlockedByClient":return v(S.prerenderFinalStatusResourceLoadBlockedByClient);default:return e.i18n.lockedString(`Unknown failure reason: ${t}`)}}static prefetchAttemptToFailureDescription({prefetchStatus:t}){switch(t){case null:case"PrefetchNotStarted":case"PrefetchNotFinishedInTime":case"PrefetchResponseUsed":case"PrefetchAllowed":case"PrefetchHeldback":case"PrefetchSuccessfulButNotUsed":return null;case"PrefetchFailedIneligibleRedirect":return f.PrefetchFailedIneligibleRedirect.name();case"PrefetchFailedInvalidRedirect":return f.PrefetchFailedInvalidRedirect.name();case"PrefetchFailedMIMENotSupported":return f.PrefetchFailedMIMENotSupported.name();case"PrefetchFailedNetError":return f.PrefetchFailedNetError.name();case"PrefetchFailedNon2XX":return f.PrefetchFailedNon2XX.name();case"PrefetchFailedPerPageLimitExceeded":return f.PrefetchFailedPerPageLimitExceeded.name();case"PrefetchIneligibleRetryAfter":return f.PrefetchIneligibleRetryAfter.name();case"PrefetchEvicted":return f.PrefetchEvicted.name();case"PrefetchIsPrivacyDecoy":return f.PrefetchIsPrivacyDecoy.name();case"PrefetchIsStale":return f.PrefetchIsStale.name();case"PrefetchNotEligibleBrowserContextOffTheRecord":return f.PrefetchNotEligibleBrowserContextOffTheRecord.name();case"PrefetchNotEligibleDataSaverEnabled":return f.PrefetchNotEligibleDataSaverEnabled.name();case"PrefetchNotEligibleExistingProxy":return f.PrefetchNotEligibleExistingProxy.name();case"PrefetchNotEligibleHostIsNonUnique":return f.PrefetchNotEligibleHostIsNonUnique.name();case"PrefetchNotEligibleNonDefaultStoragePartition":return f.PrefetchNotEligibleNonDefaultStoragePartition.name();case"PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy":return f.PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy.name();case"PrefetchNotEligibleSchemeIsNotHttps":return f.PrefetchNotEligibleSchemeIsNotHttps.name();case"PrefetchNotEligibleUserHasCookies":return f.PrefetchNotEligibleUserHasCookies.name();case"PrefetchNotEligibleUserHasServiceWorker":return f.PrefetchNotEligibleUserHasServiceWorker.name();case"PrefetchNotUsedCookiesChanged":return f.PrefetchNotUsedCookiesChanged.name();case"PrefetchProxyNotAvailable":return f.PrefetchProxyNotAvailable.name();case"PrefetchNotUsedProbeFailed":return f.PrefetchNotUsedProbeFailed.name();case"PrefetchNotEligibleBatterySaverEnabled":return f.PrefetchNotEligibleBatterySaverEnabled.name();case"PrefetchNotEligiblePreloadingDisabled":return f.PrefetchNotEligiblePreloadingDisabled.name();default:return e.i18n.lockedString(`Unknown failure reason: ${t}`)}}}const b=n.RenderCoordinator.RenderCoordinator.instance();class N extends i.LegacyWrapper.WrappableComponent{static litTagName=s.literal`devtools-resources-preloading-details-report-view`;#e=this.attachShadow({mode:"open"});#t=null;connectedCallback(){this.#e.adoptedStyleSheets=[u]}set data(e){this.#t=e,this.#r()}async#r(){await b.write("PreloadingDetailsReportView render",(()=>{if(null===this.#t)return void s.render(s.html` <div class="preloading-noselected"> <div> <p>${v(S.selectAnElementForMoreDetails)}</p> </div> </div> `,this.#e,{host:this});const t=w.action(this.#t.preloadingAttempt),r=w.detailedStatus(this.#t.preloadingAttempt);s.render(s.html` <${o.ReportView.Report.litTagName} .data="${{reportTitle:"Preloading Attempt"}}"> <${o.ReportView.ReportSectionHeader.litTagName}>${v(S.detailsDetailedInformation)}</${o.ReportView.ReportSectionHeader.litTagName}> <${o.ReportView.ReportKey.litTagName}>${e.i18n.lockedString("URL")}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> <div class="text-ellipsis" title="${this.#t.preloadingAttempt.key.url}">${this.#t.preloadingAttempt.key.url}</div> </${o.ReportView.ReportValue.litTagName}> <${o.ReportView.ReportKey.litTagName}>${v(S.detailsAction)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> <div class="text-ellipsis"> ${t} </div> </${o.ReportView.ReportValue.litTagName}> <${o.ReportView.ReportKey.litTagName}>${v(S.detailsStatus)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> ${r} </${o.ReportView.ReportValue.litTagName}> ${this.#a()} ${this.#i()} ${this.#t.ruleSets.map((e=>this.#n(e)))} </${o.ReportView.Report.litTagName}> `,this.#e,{host:this})}))}#a(){t(this.#t);const e=this.#t.preloadingAttempt;if("Prefetch"!==e.action)return s.nothing;const r=w.prefetchAttemptToFailureDescription(e);return null===r?s.nothing:s.html` <${o.ReportView.ReportKey.litTagName}>${v(S.detailsFailureReason)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> ${r} </${o.ReportView.ReportValue.litTagName}> `}#i(){t(this.#t);const e=this.#t.preloadingAttempt;if("Prerender"!==e.action)return s.nothing;const r=w.failureReason(e);return null===r?s.nothing:s.html` <${o.ReportView.ReportKey.litTagName}>${v(S.detailsFailureReason)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> ${r} </${o.ReportView.ReportValue.litTagName}> `}#n(e){const t=JSON.stringify(JSON.parse(e.sourceText));return s.html` <${o.ReportView.ReportKey.litTagName}>${v(S.detailsRuleSet)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> <div class="text-ellipsis"> ${t} </div> </${o.ReportView.ReportValue.litTagName}> `}}a.CustomElements.defineComponent("devtools-resources-preloading-details-report-view",N);var P=Object.freeze({__proto__:null,PreloadingDetailsReportView:N});const T=new CSSStyleSheet;T.replaceSync(":host{overflow:auto;height:100%}.preloading-container{height:100%;display:flex;flex-direction:column}.preloading-header{font-size:15px;background-color:var(--color-background-elevation-1);padding:1px 4px}.preloading-placeholder{flex-grow:1;display:flex;align-items:center;justify-content:center;font-size:13px;color:var(--color-text-secondary)}devtools-data-grid-controller{border:1px solid var(--color-details-hairline)}.inline-icon{vertical-align:text-bottom}\n/*# sourceURL=preloadingGrid.css */\n");const y={action:"Action",status:"Status"},F=e.i18n.registerUIStrings("panels/application/preloading/components/PreloadingGrid.ts",y),I=e.i18n.getLocalizedString.bind(void 0,F),{render:C,html:E}=s;class $ extends i.LegacyWrapper.WrappableComponent{static litTagName=s.literal`devtools-resources-preloading-grid`;#e=this.attachShadow({mode:"open"});#o=[];connectedCallback(){this.#e.adoptedStyleSheets=[T],this.#r()}update(e){this.#o=e,this.#r()}#r(){const t={columns:[{id:"url",title:e.i18n.lockedString("URL"),widthWeighting:40,hideable:!1,visible:!0},{id:"action",title:I(y.action),widthWeighting:15,hideable:!1,visible:!0},{id:"status",title:I(y.status),widthWeighting:15,hideable:!1,visible:!0}],rows:this.#s()};C(E` <div class="preloading-container"> <${l.DataGridController.DataGridController.litTagName} .data="${t}"> </${l.DataGridController.DataGridController.litTagName}> </div> `,this.#e,{host:this})}#s(){return this.#o.map((e=>({cells:[{columnId:"id",value:e.id},{columnId:"url",value:e.url},{columnId:"action",value:e.action},{columnId:"status",value:e.status}]})))}}a.CustomElements.defineComponent("devtools-resources-preloading-grid",$);var k=Object.freeze({__proto__:null,i18nString:I,PreloadingGrid:$});const V={detailsDetailedInformation:"Detailed information",detailsValidity:"Validity",detailsError:"Error",detailsLocation:"Location",detailsSource:"Source",validityValid:"Valid",validityInvalid:"Invalid; source is not a JSON object",validitySomeRulesInvalid:"Some rules are invalid and ignored",buttonClickToRevealInElementsPanel:"Click to reveal in Elements panel",buttonClickToRevealInNetworkPanel:"Click to reveal in Network panel"},x=e.i18n.registerUIStrings("panels/application/preloading/components/RuleSetDetailsReportView.ts",V),U=e.i18n.getLocalizedString.bind(void 0,x);const D=n.RenderCoordinator.RenderCoordinator.instance();class L extends i.LegacyWrapper.WrappableComponent{static litTagName=s.literal`devtools-resources-rulesets-details-report-view`;#e=this.attachShadow({mode:"open"});#t=null;connectedCallback(){this.#e.adoptedStyleSheets=[u]}set data(e){this.#t=e,this.#r()}async#r(){await D.write("RuleSetDetailsReportView render",(()=>{if(null===this.#t)return void s.render(s.nothing,this.#e,{host:this});const e=class{static validity({errorType:e}){switch(e){case void 0:return U(V.validityValid);case"SourceIsNotJsonObject":return U(V.validityInvalid);case"InvalidRulesSkipped":return U(V.validitySomeRulesInvalid)}}}.validity(this.#t),t=this.#t.errorMessage||"";s.render(s.html` <${o.ReportView.Report.litTagName} .data="${{reportTitle:"SpeculationRules rule set"}}"> <${o.ReportView.ReportSectionHeader.litTagName}>${U(V.detailsDetailedInformation)}</${o.ReportView.ReportSectionHeader.litTagName}> <${o.ReportView.ReportKey.litTagName}>${U(V.detailsValidity)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> <div class="text-ellipsis"> ${e} </div> </${o.ReportView.ReportValue.litTagName}> <${o.ReportView.ReportKey.litTagName}>${U(V.detailsError)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> <div class="text-ellipsis"> ${t} </div> </${o.ReportView.ReportValue.litTagName}> ${this.#l()} ${this.#d(this.#t.sourceText)} </${o.ReportView.Report.litTagName}> `,this.#e,{host:this})}))}#l(){if(t(this.#t),void 0!==this.#t.backendNodeId)return s.html` <${o.ReportView.ReportKey.litTagName}>${U(V.detailsLocation)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> <div class="text-ellipsis"> <button class="link" role="link" @click="${this.#c}" title="${U(V.buttonClickToRevealInElementsPanel)}"> <${c.Icon.Icon.litTagName} .data="${{iconName:"code-circle",color:"var(--icon-link)",width:"16px",height:"16px"}}"> </${c.Icon.Icon.litTagName}> &lt;script> </button> </div> </${o.ReportView.ReportValue.litTagName}> `;if(void 0!==this.#t.url){let e;return e=void 0===this.#t.requestId?s.nothing:s.html` <button class="link" role="link" @click="${this.#p}" title="${U(V.buttonClickToRevealInNetworkPanel)}"> <${c.Icon.Icon.litTagName} .data="${{iconName:"arrow-up-down-circle",color:"var(--icon-link)",width:"16px",height:"16px"}}"> </${c.Icon.Icon.litTagName}> </button> `,s.html` <${o.ReportView.ReportKey.litTagName}>${U(V.detailsLocation)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> <div class="text-ellipsis"> ${e} ${this.#t.url} </div> </${o.ReportView.ReportValue.litTagName}> `}throw new Error("unreachable")}async#c(){const e=this.#t?.backendNodeId||null;if(null===e)throw new Error("unreachable");const t=r.TargetManager.TargetManager.instance().scopeTarget();null!==t&&await d.Revealer.reveal(new r.DOMModel.DeferredDOMNode(t,e))}async#p(){const e=this.#t?.requestId||null;if(null===e)throw new Error("unreachable");const t=r.TargetManager.TargetManager.instance().scopeTarget()?.model(r.NetworkManager.NetworkManager)?.requestForId(e)||null;if(null===t)return;const a=p.UIRequestLocation.UIRequestLocation.tab(t,p.UIRequestLocation.UIRequestTabs.Preview,{clearFilter:!1});await d.Revealer.reveal(a)}#d(e){let t;try{t=JSON.parse(e)}catch(e){}if(void 0===t)return s.html` <${o.ReportView.ReportKey.litTagName}>${U(V.detailsSource)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> <div class="text-ellipsis"> ${e} </div> </${o.ReportView.ReportValue.litTagName}> `;const r=JSON.stringify(t);return s.html` <${o.ReportView.ReportKey.litTagName}>${U(V.detailsSource)}</${o.ReportView.ReportKey.litTagName}> <${o.ReportView.ReportValue.litTagName}> <div class="text-ellipsis"> ${r} </div> </${o.ReportView.ReportValue.litTagName}> `}}a.CustomElements.defineComponent("devtools-resources-rulesets-details-report-view",L);var M=Object.freeze({__proto__:null,RuleSetDetailsReportView:L});const O=new CSSStyleSheet;O.replaceSync(":host{overflow:auto;height:100%}.ruleset-container{height:100%;display:flex;flex-direction:column}devtools-data-grid-controller{border:1px solid var(--color-details-hairline)}.inline-icon{vertical-align:text-bottom}\n/*# sourceURL=ruleSetGrid.css */\n");const A={validity:"Validity",location:"Location"},B=e.i18n.registerUIStrings("panels/application/preloading/components/RuleSetGrid.ts",A),q=e.i18n.getLocalizedString.bind(void 0,B);class H extends i.LegacyWrapper.WrappableComponent{static litTagName=s.literal`devtools-resources-ruleset-grid`;#e=this.attachShadow({mode:"open"});#o=[];connectedCallback(){this.#e.adoptedStyleSheets=[O],this.#r()}update(e){this.#o=e,this.#r()}#r(){const e={columns:[{id:"validity",title:q(A.validity),widthWeighting:10,hideable:!1,visible:!0},{id:"location",title:q(A.location),widthWeighting:80,hideable:!1,visible:!0}],rows:this.#s()};s.render(s.html` <div class="ruleset-container"> <${l.DataGridController.DataGridController.litTagName} .data="${e}"> </${l.DataGridController.DataGridController.litTagName}> </div> `,this.#e,{host:this})}#s(){return this.#o.map((e=>({cells:[{columnId:"id",value:e.id},{columnId:"validity",value:e.validity},{columnId:"location",value:e.location}]})))}}a.CustomElements.defineComponent("devtools-resources-ruleset-grid",H);var K=Object.freeze({__proto__:null,i18nString:q,RuleSetGrid:H});const _={preloadingUsedForThisPage:"Preloading used for this page",prefetchUsed:"{PH1} prefetched resources are used for this page",prerenderUsed:"This page was prerendered"},j=e.i18n.registerUIStrings("panels/application/preloading/components/UsedPreloadingView.ts",_),G=e.i18n.getLocalizedString.bind(void 0,j),W=n.RenderCoordinator.RenderCoordinator.instance();class z extends i.LegacyWrapper.WrappableComponent{static litTagName=s.literal`devtools-resources-used-preloading-view`;#e=this.attachShadow({mode:"open"});#t=[];connectedCallback(){this.#e.adoptedStyleSheets=[]}set data(e){this.#t=e,this.#r()}async#r(){await W.write("UsedPreloadingView render",(()=>{const t=this.#t.filter((e=>"Success"===e.status)),r=t.filter((e=>"Prefetch"===e.key.action)).length,a=t.length-r;let i="";0===t.length?i=e.i18n.lockedString("No preloading was used for this page."):a>0?i=G(_.prerenderUsed):r>0&&(i=G(_.prefetchUsed,{PH1:r})),s.render(s.html` <${o.ReportView.Report.litTagName} .data="${{reportTitle:G(_.preloadingUsedForThisPage)}}"> <${o.ReportView.ReportSection.litTagName}> ${i} </${o.ReportView.ReportSection.litTagName}> </${o.ReportView.Report.litTagName}> `,this.#e,{host:this})}))}}a.CustomElements.defineComponent("devtools-resources-used-preloading-view",z);var X=Object.freeze({__proto__:null,UsedPreloadingView:z});export{P as PreloadingDetailsReportView,k as PreloadingGrid,M as RuleSetDetailsReportView,K as RuleSetGrid,X as UsedPreloadingView};
